
package appbatlles;

import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import recursos.images;


public class JframeTablero extends javax.swing.JFrame{
    
    Image tablero;
    Image tableroEl;
    int estadoJug = 0;
    
    int TableroJug[] [] = new int [10][10];
    int TableroOp[] [] = new int [10][10];
    
    public void inicioJug(){
        for (int n = 0; n<10; n++){
            for (int m = 0; m<10; m++){
                TableroJug[n][m]=0;
                TableroOp[n][m]=0;
            }
    
        }
    }

    public JframeTablero() {
        
        images i = new images();
        tablero = i.cargar("Batalla Naval_3.jpg");
        tableroEl = i.cargar("Batalla Naval_otro.jpg");
        initComponents();
        setBounds(0, 0, 800, 400);
        
    }
    public void pintarTablero(Graphics g, int tab [][], int x, int y){
        for (int n = 0; n<10; n++){
            for (int m = 0; m<10; m++){
                if (tab[n][m]==0){
                    g.drawRect(x+n*28, y+m*22, 28, 22);
                }
            }
        }
    
    }
    
    public void paint(Graphics g){
        g.drawImage(tablero, 20, 20, this);
        g.drawImage(tableroEl, 430, 20, this);
        pintarTablero(g, TableroJug, 70, 80);
        pintarTablero(g, TableroOp, 480, 80);
        
      
      }



    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(JframeTablero.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(JframeTablero.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(JframeTablero.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JframeTablero.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JframeTablero().setVisible(true);
            }
        });
    }
}
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

